home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 018a / amac41.zip / JMPPOS11.QM < prev    next >
Text File  |  1991-05-22  |  22KB  |  438 lines

  1. *                          JMPPOS11.QM   ver. 1.1a             May 22, 1991
  2. *                     Jump to Position Macros for QEdit
  3. * ┌──────────────────────────────[ Index ]────────────────────────────────┐
  4. * │
  5. * │   @(1) Set Position Marker at Current Line                         |chg
  6. * │   @(2) Set Position Marker at Top of Screen                        |chg
  7. * │
  8. * │   @(3) Jump to Previous Position Marker in Current File
  9. * │   @(4) Jump to Next Position Marker in Current File
  10. * │
  11. * │   @(5) Jump to Previous Position Marker in Loaded Files            |chg
  12. * │   @(6) Jump to Next Position Marker in Loaded Files                |chg
  13. * │
  14. * │   @(7) Jump to Previous Position Marker in Current File, Wraps File
  15. * │   @(8) Jump to Next Position Marker in Current File, Wraps File
  16. * │
  17. * │   @(9) Delete All Position Markers in Current File
  18. * │   @(0) Delete All Position Markers in All Loaded Files
  19. * │
  20. * └───────────────────────────────────────────────────────────────────────┘
  21.  
  22. * Written by: Tom Hogshead and John Goodman
  23.  
  24. * Description:
  25. * ------------
  26.  
  27. * The following set of QEdit macros provides an alternative to the
  28. * "bookmarking" macros in BOOKxx.QM. The JMPPOS macros allow the user
  29. * to set "Position Markers" at various points in a file, then jump
  30. * quickly to the next or previous position marker from anywhere in the
  31. * file. Position markers are "labels" that are placed any where on
  32. * separate lines in a file enabling us to jump to the next or previous
  33. * position marker in any of the currently loaded files (that is, jump
  34. * across files).
  35.  
  36. * A typical application of these macros is to set position markers at
  37. * the top of each function/subroutine in a source code file, or each
  38. * section and chapter of a documentation file.  The JMPPOS macros will
  39. * allow you to jump quickly from function to function or section to
  40. * section by pressing a single key.
  41.  
  42. * Another application of these macros is to jump quickly between
  43. * browsing a calling and called function in a source code file.  When
  44. * browsing the calling function, press one of the "Set Position Marker"
  45. * macro keys to mark the calling function's position.  Then move to the
  46. * called function and mark it's position in the same way. You can then
  47. * quickly alternate between browsing the calling and called functions
  48. * by pressing one of the "Jump to Next Position Marker" or "Jump to
  49. * Previous Position Marker" macro keys.
  50.  
  51. * The following describes the functions of the JMPPOS macro keys:
  52.  
  53. * Position markers are "labels" that are placed on separate lines in a
  54. * file.  These position markers can be placed in a file (set) using two
  55. * different macro keys, @1 or @2:
  56.  
  57. * @1 - Places a position marker one line above the line currently being
  58. *      edited.  This macro key is useful for marking specific line
  59. *      locations in a file that you'll want to jump back to later.
  60.  
  61. * @2 - Places a position marker one line above the top line currently
  62. *      displayed on the screen.  This macro key is useful for taking a
  63. *      "snapshot" of the currently displayed screen so that you can
  64. *      return to the location and have the screen displayed just as it
  65. *      was when the position marker was set.  Note that when a position
  66. *      marker is set using this macro key, nothing appears to happen.
  67. *      This is because the position marker label is placed one line
  68. *      above the first line displayed on the screen and the cursor is
  69. *      returned to its original position.
  70.  
  71. * Six different macro keys are provided to "Jump to Position Markers":
  72.  
  73. * @3 - Jumps to the previous position marker in the file currently
  74. *      being edited.  The macro searches from one line above the line
  75. *      at the top of the screen to the beginning of the file.
  76.  
  77. * @4 - Jumps to the next position marker in the file currently being
  78. *      edited.  The macro searches from the current cursor location to
  79. *      the end of the file.
  80.  
  81. * @5 - Jumps to the previous position marker in any of the files that
  82. *      are currently loaded.  The macro first searches from one line
  83. *      above the line at the top of the screen to the beginning of the
  84. *      current file, then searches from bottom to top in the previous
  85. *      file in the file ring, then moves to the nextmost previous file
  86. *      in the ring, etc. If a position marker is not found in any of
  87. *      the files in the ring, the bottom of the current file is
  88. *      searched.
  89.  
  90. * @6 - Jumps to the next position marker in any of the files that are
  91. *      currently loaded.  The macro first searches from the current
  92. *      cursor position to the bottom of the current file, then searches
  93. *      from top to bottom in the next file in the file ring, then moves
  94. *      to the next file in the ring, etc.  If a position marker is not
  95. *      found in any of the files in the ring, the top of the current
  96. *      file is searched.
  97.  
  98. * @7 - Wraps within the current file when it hits the *top* of the file
  99. *      (i.e., treat the current file as a "ring" when no marker is
  100. *      found from the starting position to the *top* of the file). This
  101. *      way, hitting a jump key will come up with something if there is
  102. *      a marker anywhere in the current file. You don't have to worry
  103. *      about whether you're at the first/last position in the file. It
  104. *      also makes it easier to jump back and forth between two
  105. *      positions.
  106.  
  107. * @8 - Wraps within the current file when it hits the *bottom* of the
  108. *      file and no marker has been found from the starting position to
  109. *      the *bottom*.
  110.  
  111. * When a position marker is found by any of the above macros, the line
  112. * containing the position marker is moved one line above the current
  113. * display.  If the position marker was set using @2, the screen will
  114. * appear just as it did when the position marker was set (except that
  115. * the cursor is placed at the top of the screen).  If a position marker
  116. * is not found by any of the jump macros, the cursor will be left at
  117. * its original location (or at the beginning of the same line if
  118. * searching backwards).
  119.  
  120. * Two keys are provided to Delete Position Markers:
  121.  
  122. * @9 - Deletes all position marker label lines in the current file.
  123.  
  124. * @0 - Deletes all position marker label lines in all currently loaded
  125. *      files.
  126.  
  127. * A few notes:
  128.  
  129. * a.  The "Jump to Position Marker" macros do not set or use any
  130. *     blocks. Block copies and moves can therefore be performed when
  131. *     jumping between positions.
  132.  
  133. * b.  In this version, the position marker label lines include an
  134. *     asterisk in column 1.  This was done so that if the user
  135. *     inadvertantly (or intentionally) does not delete the label lines
  136. *     when saving the file, the label lines will be treated as comments
  137. *     by dBase or QConfig/QMac (still need to watch out for comments in
  138. *     the middle of multi-line statements!).  If you commonly use these
  139. *     macros for other languages (e.g., C source code files), you may
  140. *     want to change the "Set Position Marker" macros to use different
  141. *     initial characters.  The other macros should not need to be
  142. *     changed.
  143.  
  144. * c.  The user may wish to add numbers or letters at the end of the
  145. *     position marker labels to uniquely identify different positions
  146. *     in a file.  For example, you might create the macros @a and @b
  147. *     that set "Position Marker A" and "Position Marker B",
  148. *     respectively.  You could then create the macros ^a and ^b that
  149. *     would search only for "Position Marker A's" and "Position Marker
  150. *     B's", respectively.  A variation of this sort would require very
  151. *     few modifications to the JMPPOS macros provided.
  152.  
  153. * Macros:
  154. * -------
  155. * * 
  156. * ----------------------------------------------------------------------
  157. * @(1) Set Position Marker at Current Line
  158. * ----------------------------------------------------------------------
  159. *
  160. @1  MacroBegin
  161.     InsertLine BegLine      * Insert a blank line
  162.     "*"                     * with Marker on it
  163.     CursorRight             *                                           |
  164.     #031 #030               *
  165. *
  166. * 14 bytes Mon  04-29-1991  23:34:56
  167. * 13 bytes Wed  05-22-1991  12:42:54 (TH - replaced space w/ CursorRight)
  168.  
  169. * 
  170. * ----------------------------------------------------------------------
  171. * @(2) Set Position Marker at Top of Screen
  172. * ----------------------------------------------------------------------
  173. *
  174. @2  MacroBegin
  175.     UnmarkBlock              * Ensure No Blocks Marked
  176.     DropAnchor DropAnchor    * Mark current Position
  177.     BegScreen                * Goto 1st Line of Screen
  178.     InsertLine               * Insert a Blank Line
  179.     BegLine                  * Goto to Start of Line
  180.     "*"                      * Type Pos Marker Label
  181.     CursorRight              *                                          |
  182.     #031 #030                *
  183.     ScrollDown               * Scroll Down 1 Line, Remove from View
  184.     GotoBlockBeg             * Return to Orig Position
  185.     UnmarkBlock              * Unmark the Block
  186. *
  187. * 21 bytes Tue  04-30-1991  00:40:51
  188. * 20 bytes Wed  05-22-1991  12:44:29 (TH - replaced space w/ CursorRight)
  189.  
  190. * 
  191. * ----------------------------------------------------------------------
  192. * @(3) Jump to Previous Position Marker in Current File
  193. * ----------------------------------------------------------------------
  194. *
  195. @3  MacroBegin
  196.     BegLine ScrollUp BegScreen  * Move cursor in front of Marker in
  197.                                 *  case current screen is positioned
  198.                                 *  with marker right on top
  199.     Find #031 #030 Return       * Search current file for next Marker
  200.     "B" Return                  *  backwards
  201.     Jtrue FOUND:                * If found, re-position
  202.  NOTFOUND:                      *ELSE no Marker above where we are
  203.     PrevPosition                * Return cursor to our original position
  204.     JUMP END:                   * End macro
  205.  FOUND:                         *ELSE no Marker in top of current file
  206.     MakeTopofScreen             * Put Marker line on top of screen
  207.  END:
  208.     ScrollDown                  * Remove marker line from view
  209. *
  210. * 25 bytes Fri  05-03-1991  02:06:08
  211.  
  212. * 
  213. * ----------------------------------------------------------------------
  214. * @(4) Jump to Next Position Marker in Current File
  215. * ----------------------------------------------------------------------
  216. *
  217. @4  MacroBegin
  218.     Find #031 #030 Return       * Search current file for Marker
  219.     DelLine Return              *  forwards
  220.     JFalse END:                 * If Marker found, end macro
  221.     MakeTopofScreen             * ELSE put Marker line on top of screen
  222.     ScrollDown                  *  and remove it from view
  223.  END:
  224. *
  225. * 17 bytes Mon  04-29-1991  23:33:46
  226.  
  227. * 
  228. * --------------------------------------------------------------------
  229. * @(5) Jump to Previous Position Marker in Loaded Files
  230. * ----------- REVISED  Sun  05-19-1991  20:26:29 ---------------------
  231. *
  232. @5  MacroBegin
  233.     Editfile "NUL" Return       * Load NUL file ahead of current file
  234.     DropAnchor                  * Need a block marker for StoreScrBuff  |
  235.     StoreScrBuff                * Create a buffer named                 |
  236.       CurrentFileName           *  "path:\NULpath:\NUL" eg              |
  237.       CurrentFileName           *  "c:\nulc:\nul"                       |
  238.       Return                    *                                       |
  239.     PrevFile                    * Move back to file we started in
  240.     BegLine ScrollUp BegScreen  * Move cursor in front of Marker in
  241.                                 *  case current screen is positioned
  242.                                 *  with marker right on top
  243.     Find #031 #030 Return       * Search Remainder of Current File
  244.     "B" Return                  *   for Pos Marker Label backwards
  245.     JTrue FOUND:                * If Found, Reposition
  246.                                 *ELSE no marker in top of current file
  247.     PrevPosition                * Return cursor to original position
  248.     ScrollDown                  *  and screen to original position
  249.  RINGLOOP:                      * Loop through file ring until Marker
  250.                                 *   found or begin point reached
  251.     PrevFile                    * Edit previous file in ring
  252.     Find Return "GB" Return     * Search file for Marker backwards
  253.                                 * Retain cursor pos if not found
  254.     JTrue FOUND:                * If Marker found, exit Loop
  255.     CursorDown CursorUp         * Test if file has more than one line
  256.     JTrue RINGLOOP:             * If if does, we are not in the
  257.                                 *  NUL file, move to next file
  258.     GetScrBuff                  * Try retrieving a buffer named         |
  259.       CurrentFileName           *  current file's name 2x, eg           |
  260.       CurrentFileName           * "c:\current.extc:\current.ext"        |
  261.       Return                    *                                       |
  262.     JFalse RINGLOOP:            * Buffer only exists for "c:\nulc:\nul"
  263.     Quit                        *ELSE quit NUL file and return to
  264.                                 *  file we started search in
  265.     Find Return "GB" Return     * Search bottom of original file
  266.     JFalse END:                 * Give up if not there either
  267.  FOUND:                         * Label Marker was found
  268.     MakeTopofScreen             * Position Marker line at top of screen
  269.     ScrollDown                  * Remove it from view
  270.     OneWindow                   * Close windows
  271.     HorizontalWindow            * Open one window
  272.     EditFile Return Quit        * Load NUL file in window and quit it
  273.                                 *  which closes windows and puts us
  274.                                 *  back in file with first found marker
  275.     CloseWindow                 * Needed if QConfig Close Window
  276.                                 *  Option = 'N'
  277.  END:
  278. *
  279. * 65 bytes Mon  04-29-1991  23:47:06
  280. * 77 bytes Sun  05-19-1991  20:26:05 (TH |)
  281.  
  282. * 
  283. * ----------------------------------------------------------------------
  284. * @(6) Jump to Next Position Marker in Loaded Files
  285. * ----------- REVISED  Sun  05-19-1991  20:26:47 -----------------------
  286. *
  287. @6  MacroBegin
  288.     PrevFile                    * Move to file before the one we're in
  289.     Editfile "NUL" Return       * Load NUL file in case Marker is in
  290.                                 * file we started search in
  291.     DropAnchor                  * Need a block marker for StoreScrBuff
  292.     StoreScrBuff                * Create a buffer named                 |
  293.       CurrentFileName           *  "path:\NULpath:\NUL" eg              |
  294.       CurrentFileName           *  "c:\nulc:\nul"                       |
  295.       Return                    *                                       |
  296.     NextFile                    * Move back to file we started in
  297.     Find #031 #030 Return       * Search Remainder of Current File
  298.                                 *   for Pos Marker Label
  299.     DelLine Return              *   Clear Find Prompts (Find Forward)
  300.     JTrue FOUND:                * If Found, Reposition & Cleanup
  301.  RINGLOOP:                      * Loop Through File Ring Until Marker
  302.                                 *   Found or Begin Point Reached
  303.     NextFile                    * Edit Next File in Ring
  304.     Find Return "G" Return      * Search File for Label Marker
  305.                                 *   Retain Cursor Pos If Not Found
  306.     JTrue FOUND:                * If label Marker found, exit Loop
  307.     CursorDown CursorUp         * Test if file has more than one line
  308.     JTrue RINGLOOP:             * If if does, we are not in the
  309.                                 *  NUL file, move to next file
  310.     GetScrBuff                  * Try retrieving a buffer named         |
  311.       CurrentFileName           *  current file's name 2x, eg           |
  312.       CurrentFileName           * "c:\current.extc:\current.ext"        |
  313.       Return                    *                                       |
  314.     JFalse RINGLOOP:            * Buffer only exists for "c:\nulc:\nul" |
  315.     Quit NextFile               *ELSE quit NUL file and return to
  316.                                 *  file we started search in
  317.     Find Return "G" Return      * Search Top of Original File
  318.     JFalse END:                 * Give Up If Not There Either
  319.  FOUND:                         * Label Marker Was Found
  320.     MakeTopofScreen             * Position Label Line at Top of Screen
  321.     ScrollDown                  * Remove it from View
  322.     OneWindow                   * Close windows
  323.     HorizontalWindow            * Open one window
  324.     EditFile Return Quit        * Load NUL file in window and quit it
  325.                                 *  which closes windows and puts us
  326.                                 *  back in file with first found marker
  327.     CloseWindow                 * Needed if QConfig Close Window
  328.                                 *  Option = 'N'
  329.  END:
  330. *
  331. * 57 bytes Tue  04-30-1991  00:45:00
  332. * 69 bytes Sun  05-19-1991  20:25:47 (TH |)
  333.  
  334. * 
  335. * ----------------------------------------------------------------------
  336. * @(7) Jump to Previous Position Marker in Current File, Wraps File
  337. * ----------- REVISED  Sat  05-04-1991  01:37:34 -----------------------
  338.  
  339. @7  MacroBegin
  340.     BegLine ScrollUp BegScreen  * Move cursor in front of Marker in
  341.                                 *  case current screen is positioned
  342.                                 *  with marker right on top
  343.     Find                        * Search
  344.     #031 #030 Return "B" Return *  backwards for Marker
  345.  JTrue FOUND:                   * Test if Found, go to FOUND
  346.     Prevposition                *ELSE if not found,
  347.     Find Return "GB" Return     * Do global search from bottom up
  348.                                 * Keeps starting cursor position
  349.                                 *  if no marker in file
  350.     Jfalse END:                 * Test if not found, end macro
  351.  FOUND:                         *ELSE marker was found
  352.     MakeTopofScreen             * Position Label Line at Top of Screen
  353.  END:                           *
  354.     ScrollDown                  * Remove it from View
  355. *
  356. * 32 bytes Sat  05-04-1991  01:36:19
  357.  
  358. * 
  359. * ----------------------------------------------------------------------
  360. * @(8) Jump to Next Position Marker in Current File, Wraps File
  361. * ----------------------------------------------------------------------
  362.  
  363. @8  MacroBegin
  364.     Find                             * Search Down for Pos Marker Label
  365.     #031 #030  Return DelLine Return *
  366.  JTrue FOUND:                        * Test if Found
  367.     BegFile                          * If Not, Start at Top of File
  368.     RepeatFind                       * and Repeat the Search
  369.  JTrue FOUND:                        * Test if Now Found
  370.     PrevPosition                     * No Label in File, Return to
  371.     MakeCtrofScreen                  * orig Position and Center
  372.  Jump END:
  373.  FOUND:                              * Label Was Found
  374.     MakeTopofScreen                  * Position Label Line at Top of Screen
  375.     ScrollDown                       * Remove it from View
  376.  END:
  377. *
  378. * 28 bytes Fri  05-03-1991  02:48:51
  379.  
  380. * 
  381. * -------------------------------------------------------------------------
  382. * @(9) Delete All Position Markers in Current File
  383. * -------------------------------------------------------------------------
  384. *
  385. @9  MacroBegin
  386.     InsertLine #224             * Insertline w/ weird character
  387.  FILELOOP:                      * Loop until all Markers are deleted
  388.     Find #031 #030 Return       * Search file for next label Marker
  389.     "G" Return                  * Retain cursor pos if not found
  390.     JFalse FILECLEAN:           * Label Marker not found, exit loop
  391.     DelLine                     * Label Marker found, del the line
  392.     Jump FILELOOP:              * See if more Markers in current file
  393.  FILECLEAN:                     * File now clean of Markers
  394.     Find #224 Return "G" Return * Search file for begin point Marker
  395.     DelLine                     * Delete line w/ weird character
  396. *
  397. * 31 bytes Mon  04-29-1991  23:34:45
  398.  
  399. * 
  400. * -------------------------------------------------------------------------
  401. * @(0) Delete All Position Markers in All Loaded Files
  402. * -------------------------------------------------------------------------
  403.  
  404. @0  MacroBegin
  405.     InsertLine #224          * InsertLine w/ Weird Character
  406.   RINGLOOP:                  * Loop Through File Ring Until
  407.                              *   Begin Point Reached
  408.     NextFile                 * Edit Next File in Ring
  409.     FILELOOP:                * Loop Until All Markers in
  410.                              *   File are Deleted
  411.       Find                   * Search File
  412.         #031 #030  Return    *   for Next Label Marker
  413.         "G" Return           *   Retain Cursor Pos If Not Found
  414.       JFalse FILECLEAN:      * Label Marker Not Found, Exit Loop
  415.       DelLine                * Label Marker Found, Del the Line
  416.     Jump FILELOOP:           * See if More Markers in Current File
  417.     FILECLEAN:               * File Now Clean of Markers
  418.     Find                     * Search File
  419.       #224 Return            *   for Begin Point Marker
  420.       "G" Return
  421.   JFalse RINGLOOP:           * Begin Point Not Found, Try Next File
  422.                              * If Here, All Markers Deleted and
  423.                              *   Back to Starting Point
  424.     DelLine                  * Delete line with Marker in Original File
  425. *
  426. * 35 bytes Tue  04-30-1991  00:53:21
  427.  
  428. * Version History:
  429. * ----------------
  430. *   1.0     May 3, 1991   Initial.
  431. *   1.0a    May 4, 1991   Changed @7 to return to starting position if
  432. *                         no marker found.
  433. *   1.0b    May 4, 1991   Decscription of @4 and @5 were switched. Corrected.
  434. *   1.0c    May 10, 1991  Minor documentation changes.
  435. *   1.1     May 19, 1991  Modified @5 and @6 to use scratch buffer test
  436. *                         for all file and cursor position cases.
  437. *   1.1a    May 22, 1991  Shortened @1 and @2 one byte each.
  438.